/********************************************************************
	created:	2010/01/15
	created:	15:1:2010   14:23
	filename: 	qyFixedColor4.h
	author:		Xiong Jiayu
	copyright:  
	purpose:	
*********************************************************************/
#pragma once

#ifndef __QYFIXEDCOLOR_H__
#define __QYFIXEDCOLOR_H__

#include "../common/qyCommon.h"
#include "qyMath.h"

/*
===========================================
struct qyFixedColor3
===========================================
*/
struct qyFixedColor3
{
	uint8_t r, g, b;

	qyFixedColor3();
	qyFixedColor3( const uint8_t r, const uint8_t g, const uint8_t b );
	qyFixedColor3( const qyFixedColor3 &c );
	
	void			Set( const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t a );
	uint32_t		To_ARGB( void ) const;				// to argb8888
	void			From_ARGB( const uint32_t &c );		// from argb8888
	uint32_t		To_RGBA( void ) const;				// to rgba8888
	void			From_RGBA( const uint32_t &c );		// from rgba8888

	void			AddValue( const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t a );
	void			BlendWith( const qyFixedColor3 &dest, const uint8_t destAlpha );
	void			ColorStandard();
	float			Normalize();
	float			NormalizeFast();

	qyFixedColor3 &	operator=( const qyFixedColor3 &c );
	qyFixedColor3	operator+( const qyFixedColor3 &c ) const;
	qyFixedColor3 &	operator+=( const qyFixedColor3 &c );
	qyFixedColor3	operator*( const float scale ) const;
	qyFixedColor3 &	operator*=( const float scale );
	qyFixedColor3	operator*( const qyFixedColor3 &c ) const;
	qyFixedColor3 &	operator*=( const qyFixedColor3 &c );
};

/*
===========================================
struct qyFixedColor4
===========================================
*/
struct qyFixedColor4
{
	uint8_t r, g, b, a;

					qyFixedColor4();
					qyFixedColor4( const qyFixedColor4 &c );
					qyFixedColor4( const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t a );

	void			Set( const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t a );
	uint32_t		To_ARGB( void ) const;				// to argb8888
	void			From_ARGB( const uint32_t &c );		// from argb8888
	uint32_t		To_RGBA( void ) const;				// to rgba8888
	void			From_RGBA( const uint32_t &c );		// from rgba8888

	void			AddValue( const uint8_t r, const uint8_t g, const uint8_t b, const uint8_t a );
	void			BlendWith( const qyFixedColor4 &dest, const uint8_t destAlpha );
	void			ColorStandard();
	float			Normalize();
	float			NormalizeFast();

	qyFixedColor4 &	operator=( const qyFixedColor4 &c );
	qyFixedColor4	operator+( const qyFixedColor4 &c ) const;
	qyFixedColor4 &	operator+=( const qyFixedColor4 &c );
	qyFixedColor4	operator*( const float scale ) const;
	qyFixedColor4 &	operator*=( const float scale );
	qyFixedColor4	operator*( const qyFixedColor4 &c ) const;
	qyFixedColor4 &	operator*=( const qyFixedColor4 &c );
};

#include "qyFixedColor.inl"

#endif
 